export function checkRole() {
    /**
     * type=1表示管理员，
     * type=2表示员工
     * ，type=3表示客户
     */
    let userInfo = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : null
    if (userInfo && userInfo.sysUser) {
        return userInfo.sysUser.type
    }
    if (userInfo && !userInfo.sysUser) {
        return userInfo.type
    }
    return null
}
export function getHashParameters() {
    const hash = window.location.hash
    if (hash.indexOf('?') > -1) {
        var arr = hash.split('?')[1].split('&')
        var params = {}
        for (var i = 0; i < arr.length; i++) {
            var data = arr[i].split('=')
            if (data.length === 2) {
                params[data[0]] = data[1]
            }
        }
        return params
    }
    return {}
}
//将url问号后面携带的参数转变成对象方便解析
export const searchToObj = (str) => {
    if (!str) {
        return;
    }
    str = str.substr(1);
    let arr = str.split('&'),
        obj = {},
        newArr = [];
    arr.map(function (value, index, arr) {
        newArr = value.split('=');
        if (newArr[0] != undefined) {
            obj[newArr[0]] = newArr[1];
        }
    });
    return obj;
};
/**
 * 判断当前设备是否为ios
 */
export function checkIsIOS() {
    let u = navigator.userAgent;
    let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
    return isiOS
}
/**
 *  判断当前设备是否为android
 */
export function checkIsAndroid() {
    let u = navigator.userAgent
    let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1
    if (isAndroid) {
        return true
    } else {
        return false
    }
}